package com.wc.codeforces.思维.Turtle_Tenacity_Continual_Mods;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/6/24 20:17
 * @description https://codeforces.com/problemset/problem/1933/D
 */
public class Main {
    /**
     * 思路： 排序 + 枚举
     * 一直 x % y == x, x < y就好, 那可以让x等于最小的
     * 只需要考虑最小值是否只有一个,
     * 如果最小值不止一个, 那就看其他的数是否可以mod最小值不等于0, 那就说明可以得到比最小的值小一点的一个出来就也可以以满足
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 200010, INF = 0x3f3f3f3f;
    static int[] a = new int[N];
    static int n;

    public static void main(String[] args) {
        int T = sc.nextInt();
        while (T-- > 0) {
            n = sc.nextInt();
            int t = INF;
            for (int i = 1; i <= n; i++) {
                a[i] = sc.nextInt();
                t = Math.min(t, a[i]);
            }
            int num = 0;
            for (int i = 1; i <= n; i++) {
                if (a[i] == t) num++;
            }
            if (num == 1) out.println("YES");
            else {
                if (t == 1) out.println("NO");
                else {
                    boolean res = false;
                    for (int i = 1; i <= n; i++) {
                        if (a[i] % t > 0) {
                            res = true;
                            break;
                        }
                    }
                    if (res) out.println("YES");
                    else out.println("NO");
                }
            }
        }
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
